import React from 'react'
import getProductBySlug from '@/ssr/getProductBySlug';
import ProductTemplate from '@/template/products/ProductTemplate';
import getContact from "@/ssr/getContact";

export async function generateMetadata({params}) {
  const contact = await getContact();
  const {slug} = await params;
  const {product} = await getProductBySlug(slug);
  return {
    title: product.meta_title ? product.meta_title : `${product.title} | ${contact.meta_title || contact.name}`,
    description: product.meta_description ? product.meta_description : `${contact.meta_description || contact.description}`,
  };
}

export default async function Page({params}) {
  const { slug } = await params;
  const data = await getProductBySlug(slug);
  return ( <ProductTemplate info={data} template={data.product.template}/> )
}
